from django.http import HttpResponse
from django.template import Context, loader
from django.shortcuts import get_object_or_404, render_to_response
from helloworld.coder.models import Poll


def index(request):
	template = loader.get_template('coder/index.html')
	latest_poll = Poll.objects.all().order_by('-pub_date')[:5]
	
	context = Context({
		'latest_poll' : latest_poll
	})
	return HttpResponse(template.render(context))

def detail(request, poll_id):
        info = Poll.objects.get(id=poll_id)
        context = Context({
                'poll_info' : info
                })
        template = loader.get_template('coder/detail.html')
	return HttpResponse(template.render(context))

def info(request, poll_id):
	   nextInfo = int( poll_id ) + 1
	   context = Context({
					    'next_info': nextInfo
					    })
	   return render_to_response('coder/info.html', {'next_info': nextInfo})